package demo1;

import java.util.Arrays;

public class LeetCode179 {
    public int[] twoSum(int[] price, int target) {
        Arrays.sort(price);
        int left = 0, right = price.length - 1;
        while(left < right) {
            if(price[left] + price[right] < target) left++;
            else if(price[left] + price[right] > target) right--;
            else return new int[]{price[left],price[right]};
        }
        return new int[]{0};
    }
}
